package com.estudos.util;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import exception.ConexaoException;

public class ConexaoHibernate {
	public static EntityManager getManager() throws ConexaoException{
		EntityManagerFactory factory;
		EntityManager manager = null;
		try {
			factory = Persistence.createEntityManagerFactory("estudos");
			manager = factory.createEntityManager();
			System.out.println("aaaaaaaaaaaaaa Criou o Manager Entity");
		} catch (Exception e) {
			e.printStackTrace();
			throw  new ConexaoException("Erro ao tentar criar Entity Manager!");
		}
		return manager;
	}
}
